class Solution3 {
    public int mySqrt(int x) {

        int left=0,right=x,mid;

        //寻找左区间
        while(left!=right){
            mid=(left+right)/2;
            if((long)mid*mid>x){
                right=mid-1;
            }else{
                left=mid;
            }
        }
        right=left+1;
        return (left+right)/2;
    }
}
public class demo5 {
    public static void main(String[] args) {
        int[] nums={1,3,5,7};
        int target=2147483647;
        int a=new Solution3().mySqrt(target);
        System.out.println(a);
    }
}
